Page({
  data: {
    longitude: 113.324520,
    latitude: 23.099994,
    markers: [{
      id: 0,
      iconPath: "../../resources/location.jpg",
      latitude: 23.099994,
      longitude: 113.324520,
      width: 50,
      height: 50
    }]
  },
  //获取当前位置
  controlshandler(event) {
    console.log(event)
    // 如果是定位的小图标
    if (event.controlId === 1) {
      // 获取本认所在地的经纬度 ---- 调用微信的定位功能
      // api-位置 https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html
      wx.getLocation({
        success: (res) => {
          console.log(res)
          const { longitude, latitude } = res
          this.setData({
            longitude, latitude,
            
          })
        }
      })
    }
  },
  onLoad: function () {
    // var that = this;
    // wx.getLocation({
    //   type: "wgs84",
    //   success: function (res) {
    //     var latitude = res.latitude;
    //     var longitude = res.longitude;
    //     console.log(res)
    //     console.log(res.latitude);
    //     that.setData({
    //       latitude: res.latitude,
    //       longitude: res.longitude,
    //       markers: [{
    //         latitude: res.latitude,
    //         longitude: res.longitude
    //       }]
    //     })
    //   }
    // })
  },
  onReady: function () {

  },
  onShow: function () {
    var _this = this;
    _this.controlshandler()
  }
})